package com.itheima.capsulation;

public class Dog {

    //合理隐藏，使用private关键字修饰成员变量，
    //只能在当前类中直接访问，其他地方不行
    private int age;
    private double weight;
    private String name;
    private String color;

    //合理公开，使用public关键字修饰的set和get方法
    public void setAge(int age) {
        if (age > 0) {
            this.age = age;

        } else {
            System.out.println("年龄不合法");
        }
    }

    public int getAge() {
        return age;
    }

    public void setWeight(double weight) {
        if (weight > 0) {
            this.weight = weight;
        } else {
            System.out.println("体重不合法");
        }
    }

    public double getWeight() {
        return weight;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getColor() {
        return color;
    }

}
